﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ThucThe;
using System.Data;

namespace KetNoi
{
    public class NhanVien_ketnoi
    {
        clsKetNoi kn = new clsKetNoi();
        public DataTable danhSachNhanVien()
        {
            return kn.LayDuLieu("NhanVien_load");
        }
        public int Them_NhanVien(NhanVien_thucthe nv)
        {
            int Nparameter = 9;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@tenNhanVien"; value[0] = nv.TenNhanVien;
            name[1] = "@ngaySinh"; value[1] = nv.NgaySinh;
            name[2] = "@gioiTinh"; value[2] = nv.GioiTinh;
            name[3] = "@sdt"; value[3] = nv.Sdt;
            name[4] = "@email"; value[4] = nv.Email;
            name[5] = "@diaChi"; value[5] = nv.DiaChi;
            name[6] = "@chucVu"; value[6] = nv.ChucVu;
            name[7] = "@matKhau"; value[7] = nv.MatKhau;
            name[8] = "@quyen"; value[8] = nv.Quyen;
            return kn.CapNhat("NhanVien_them", name, value, Nparameter);
        }
        public int Sua_NhanVien(NhanVien_thucthe nv)
        {
            int Nparameter = 10;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@maNhanVien"; value[0] = nv.MaNhanVien;
            name[1] = "@tenNhanVien"; value[1] = nv.TenNhanVien;
            name[2] = "@ngaySinh"; value[2] = nv.NgaySinh;
            name[3] = "@gioiTinh"; value[3] = nv.GioiTinh;
            name[4] = "@sdt"; value[4] = nv.Sdt;
            name[5] = "@email"; value[5] = nv.Email;
            name[6] = "@diaChi"; value[6] = nv.DiaChi;
            name[7] = "@chucVu"; value[7] = nv.ChucVu;
            name[8] = "@matKhau"; value[8] = nv.MatKhau;
            name[9] = "@quyen"; value[9] = nv.Quyen;
            return kn.CapNhat("NhanVien_sua", name, value, Nparameter);
        }
        public int Xoa_NhanVien(NhanVien_thucthe nv)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@maNhanVien";
            value[0] = nv.MaNhanVien;
            return kn.CapNhat("NhanVien_xoa", name, value, Nparameter);
        }
        public DataTable Tim_NhanVien(NhanVien_thucthe nv)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@tenNhanVien";
            value[0] = nv.TenNhanVien;
            return kn.TimKiem("NhanVien_tim", name, value, Nparameter);
        }
        public DataTable DangNhap(NhanVien_thucthe nv)
        {
            int Nparameter = 2;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@maNhanVien";
            value[0] = nv.MaNhanVien;
            name[1] = "@maKhau";
            value[1] = nv.MatKhau;
            return kn.TimKiem("dangNhap", name, value, Nparameter);
        }
    }
}
